package com.lnu.information.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author : jian.zhang-2
 * @description:
 * @date : Create in 10:36 PM 2022/3/8
 * @modified By :
 */
//表明当前类是配置类
@Configuration
//表示开启生成接口文档功能（只有开启了OpenApi,才可以实现生成接口文档的功能）
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lnu.information"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("transformer项目接口文档")
                .description("更多请咨询服务开发者")
                //版本
                .version("1.0")
                .build();
    }
}
